package com.heima.kafka.producer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProducerController {

    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    @GetMapping("/kafka")
    public String kafkaTest(){
        kafkaTemplate.send("kafka-topic","hello kafka");
        return "ok";
    }

    @GetMapping("/kafka2")
    public String kafkaTest2(){
        kafkaTemplate.send("kafka-topic","hello itcast");
        return "ok";
    }
}
